package com.xuecheng.learning.controllor;

import com.example.content.model.dto.XcChooseCourseDto;
import com.example.content.model.dto.XcCourseTablesDto;
import com.xuecheng.config.XueChengPlusException;
import com.xuecheng.learning.service.MyCourseTablesService;
import com.xuecheng.learning.util.SecurityUtil;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@Slf4j
@RestController
public class MyCourseTablesControllor {
    @Resource
    MyCourseTablesService myCourseTablesService;
    @ApiOperation("添加选课")
    @PostMapping("/choosecourse/{courseId}")
    public XcChooseCourseDto addChooseCourse(@PathVariable("courseId")Long courseId){
        //当前登录的用户
//        SecurityUtil.XcUser user = SecurityUtil.getUser();
//        if(user == null){
//            XueChengPlusException.cast("请登录");
//        }
//        //用户id
//        String userId = user.getId();
        XcChooseCourseDto xcChooseCourseDto = myCourseTablesService.addChooseCourse("52", courseId);
        return xcChooseCourseDto;
    }
//    查询学习资格
    @PostMapping("/choosecourse/learnstatus/{courseId}")
    public XcCourseTablesDto getLearningStatus(@PathVariable("courseId")Long courseId){
        XcCourseTablesDto xcCourseTablesDto = myCourseTablesService.getLearningStatus("52", courseId);
        return xcCourseTablesDto;
    }
}
